<template>
  <div class="finance">
    <div
      class="container-fluid"
      style="background-color:#fff;margin:0px;border-bottom-color:#dddddd;border-bottom-width:1px;border-bottom-style:solid"
    >
      <!-- 导航 -->
      <div class="container daohang">
        <div class="col-sm-2" style="padding:0px;color:#555;">
          <h4>
            <strong>
              <i class="icon iconfont icon-folder" style="font-size:20px"></i> 分类电子书
            </strong>
          </h4>

          <p style="font-size:13px">
            <a href="/" style="color:#000;">主页</a> »
            <a href="/" style="color:#000;">SAP电子书</a>»
            <a href="/" style="color:#000;">财务</a>
          </p>
        </div>
        <!-- 导航左侧跳动文字 -->
        <div class="word">
          <span class="one glyphicon glyphicon-volume-up" aria-hidden="true"></span>
          <ul>
            <li v-for="item in wordList" :key="item.id">
              <span>{{item.ti}}</span>
              <strong style="color:#ff0000" v-show="item.str">{{item.str}}</strong>
              <span v-show="item.wei">{{item.wei}}</span>
            </li>
          </ul>
        </div>

        <!-- 导航右侧搜索 -->
        <div class="search clearfix">
          <div
            class="input-group navbar-form navbar-right"
            style="width:200px;margin:0px;padding:5px;"
            role="search"
          >
            <input
              type="text"
              id="Keyword"
              name="keyword"
              required
              class="form-control input-sm"
              placeholder="搜索本站SAP资料"
            />
            <div class="input-group-btn">
              <input type="button" id="Search" class="btn btn-default btn-sm" value="Go!" />
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- 内容 -->
    <div class="container leave container_d">
      <!-- 图片瀑布流显示 -->
      <div class="content_imgText left_d">
        <waterfall
          style="height: 100%;"
          :col="col"
          :width="itemWidth"
          :gutterWidth="gutterWidth"
          :data="datalist"
        >
          <template>
            <div class="cell-item" v-for="item in datalist" :key="item.id">
              <a href style="color:#808080;">
                <img :src="item.src" alt style="width: 157px;" />
                <i>{{item.title}}</i>
              </a>
            </div>
          </template>
        </waterfall>
        <div>
          <el-pagination
            background
            :page-size="25"
            layout="prev, pager, next"
            :total="total"
            :current-page="queryinfo.pagenum-0"
            @current-change="handleCurrentChange"
            @size-change="handleSizeChange"
          ></el-pagination>
        </div>
      </div>
      <div class="right_top clearfix">
        <!-- 图书标签 -->
        <div class="right_top_d">
          <div class="right_child_top">
            <span>
              <a href>
                <i>图书标签</i>
              </a>
            </span>
          </div>
          <div class="eBook-label">
            <span
              v-for="(item, index) in bookLabel"
              :key="index"
              :class="['pad', 'label', csLabel(index)]"
            >
              {{item.txt}}
              <span class="badge">{{item.num}}</span>
            </span>
          </div>
        </div>
        <div class="right_con_d">
          <div class="right_child_top">
            <span>
              <a href="/textbook" style="color:#333;">
                <strong>SAP PA标准教材下载</strong>
              </a>
            </span>
          </div>
          <div class="right_child_bottom"></div>
          <p
            style="font-size:12px;margin:5px;padding:5px;border-bottom:1px solid #e7e7e7"
            v-for="itemlist in nameList"
            :key="itemlist.id"
          >
            <a href>{{itemlist.title}}</a>
          </p>
        </div>
        <!-- 连接 -->
        <div class="right_bottom_d">
          <div class="right_child_top">
            <span>
              <a href style="color:#333;">
                <i>友情链接</i>
              </a>
            </span>
          </div>
          <div class="right_child_bottom_second">
            <a href>
              <img src="../../assets/friendslian.png" alt />
              <p>JavaWeb开发者社区</p>
            </a>
          </div>
        </div>
      </div>
    </div>
    <!-- 底部 -->
    <div
      class="footer"
      style="height:100px;background-color:#2e2e2e;margin-top:10px;font-size:14px"
    >
      本站所有电子书全部来自于互联网，欢迎大家给小编投稿+V:FICODK
      <p>
        © 2018 All Rights Reserved by SAPDOC.cn. |
        <a
          href="http://www.miitbeian.gov.cn/"
          style="color:#e5e5e5;font-size:14px"
        >沪ICP备17005776号-3</a>
      </p>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    // let url = require("");
    return {
      // 广告
      wordList: [
        {
          ti: "SAP文库全新改版，注册最多",
          str: "赠送400积分",
          wei: "用于购买各类资料！"
        },
        {
          ti: " 欢迎猎头和HR入住，",
          str: "免费发布SAP招聘信息！本站5个微信群同步免费推送！"
        },
        {
          ti:
            "本站所有内容均来自互联网用户分享，如有违规内容，纯属本站管理不善，请及时联系我们删除。"
        }
      ],
      // 瀑布流布局
      itemWidth: null,
      gutterWidth: 10,
      col: 5,
      datalist: [],
      // 分页
      total: 0,
      queryinfo: {
        pagenum: this.getPageNum() || 1,
        pagesize: 25
      },
      // 右边标题
      nameList: [],
      bookLabel: []
    };
  },
  created() {
    setInterval(this.showMarquee, 2000);
    this.setStartPage();
    this.fetchData();
    this.titleData();
    this.getGod();
  },
  methods: {
    // 设置开始页码数
    setStartPage() {
      let page = this.getPageNum();
      if (page == undefined) {
        window.localStorage.setItem("page3", 1);
      }
    },
    // 获取页码数
    getPageNum() {
      return window.localStorage.getItem("page3");
    },
    // 广告动画
    showMarquee: function() {
      setTimeout(() => {
        this.wordList.push(this.wordList[0]);
        this.wordList.shift();
      }, 500);
    },
    // 请求数据
    async fetchData() {
      let { data: res } = await this.$axios.get("/finance", {
        params: this.queryinfo
      });
      // console.log(res.data);
      // 图片显示
      res.data.forEach(item => {
        item.src = item.src.replace(
          "../../assets",
          "http://127.0.0.1:8989/public/images"
        );
      });
      this.datalist = res.data;
      this.total = res.total;
      // console.log(this.data);
    },
    // 分页
    // 显示页面数
    handleSizeChange(size) {
      this.queryinfo.pagesize = size;
      this.fetchData();
    },
    // 页面数据显示
    handleCurrentChange(num) {
      window.localStorage.setItem("page3", num);
      this.$router.go(0);
    },
    // 右侧标题
    async titleData() {
      let { data: res } = await this.$axios.get("/title");
      // console.log(res);
      this.nameList = res.data;
    },
    // 彩色标签
    csLabel(n) {
      n = n % 6;
      switch (n) {
        case 0:
          return "label-default";
        case 1:
          return "label-primary";
        case 2:
          return "label-success";
        case 3:
          return "label-info";
        case 4:
          return "label-warning";
        case 5:
          return "label-danger";
      }
    },
    // 获取数据
    async getGod() {
      const { data: res } = await this.$axios.get("/eLabel");
      this.bookLabel = res.data.list;
      // console.log(res);
    }
  }
};
</script>

<style lang='less' scoped>
a {
  text-decoration: none;
}
.finance {
  background-color: #fcf8e3;
}

.leave {
  margin-top: 10px;
}
.word {
  float: left;
  color: #808080;
  height: 20px;
  overflow: hidden;
  margin-top: 15px;
}
span.one {
  color: #428bca;
  float: left;
  margin-right: 35px;
}
.word ul {
  float: left;
  margin-top: -1px;
}

.word li {
  background-color: #fff;
}

.search {
  position: relative;
  top: 5px;
  float: right;
}

.cell-item {
  background-color: #fff;
  width: 159px;
  margin: 5px;
  border: 1px solid #ddd;
  // box-sizing: border-box;
}

.container_d {
  margin-right: auto;
  margin-left: auto;
  position: relative;
}
.container_d > div {
  display: inline-block;
  border-radius: 4px;
}

.left_d {
  width: 845px;
  float: left;
  overflow: -Scroll;
  overflow-y: hidden;
}

.right_top {
  margin-left: 5px;
}

.right_top_d,
.right_con_d,
.right_bottom_d {
  background-color: #fff;
  border: 1px solid #ddd;
  box-sizing: border-box;
  /* margin-top: 10px; */
}

.right_con_d,
.right_bottom_d {
  margin-top: 15px;
}
.right_con_d {
  width: 285px;
}

.right_con_d a {
  text-decoration: none;
  color: #333;
  font-size: 14px;
}

.right_top_d {
  width: 285px;
  height: 450px;
  box-sizing: border-box;
  margin-top: 5px;
}
.right_top_d a {
  display: inline-block;
  position: relative;
  margin-top: 11px;
  color: #333;
}
.right_top_d i {
  font-size: 16px;
  font-weight: bold;
}
.right_bottom_d {
  width: 285px;
  height: 90px;
  bottom: 990px;
  left: 830px;
}
.right_bottom_d {
  padding: 10px;
}
.right_child_top {
  padding: 0px 10px 10px 10px;
  border-bottom: 1px solid #ddd;
}
.right_child_top span {
  padding-bottom: 11px;
  margin-bottom: -10px;
  border-bottom-color: #f98181;
  border-bottom-style: solid;
  border-bottom-width: 2px;
}

.right_child_bottom_second {
  margin-top: 10px;
}
.right_child_bottom_second p {
  display: inline-block;
}
.right_child_bottom_second img {
  width: 25px;
  height: 25px;
}

.footer {
  padding-top: 30px;
  text-align: center;
  color: #999999;
}

.el-pagination {
  margin-top: 40px;
  text-align: center;
}

/******** 图书标签 */
.eBook-label {
  width: 100%;
  height: 100%;
  padding-left: 5px;

  span.pad {
    display: inline-block;
    font-size: 12px;
    margin-bottom: 5px;
    font-weight: 400;
    margin-right: 3px;
  }

  span.badge {
    display: inline-block;
    min-width: 8px;
    padding: 2px 5px;
    font-size: 10px;
    font-weight: bold;
    color: #808080;
    line-height: 1;
    vertical-align: middle;
    white-space: nowrap;
    text-align: center;
    background-color: #fff;
    border-radius: 10px;
  }
}
</style>>

